//
//  ClassStateModel.m
//  sooc-ios_new
//
//  Created by houshijia on 16/9/25.
//  Copyright © 2016年 xuguangChao. All rights reserved.
//

#import "ClassStateModel.h"
#import "CourseDetailsModel.h"
#import "SCUDUtil.h"
#import <MJExtension/MJExtension.h>
@implementation ClassStateModel


-(instancetype)initWithDetailDictionary:(NSDictionary*)detailDictionary{
    if (self = [super init]) {
        
        _detailModel = [CourseDetailsModel mj_objectWithKeyValues:detailDictionary];
        _currentInfo = [NSMutableDictionary dictionary];
        [self analyseStateFromModel:_detailModel];
        
    }
    
    
    
    return self;
}

+(ClassStateModel*)modelWithDict:(NSDictionary*)dict{
    return [[ClassStateModel alloc]initWithDetailDictionary:dict];
}

-(void)analyseStateFromModel:(CourseDetailsModel*)model{
    
    
    if ([model.kcsd intValue]==1) {
        _ClassState = ClassStateUnopen;
        return;
    }
    if ([model.kcls intValue]==1) {
        _ClassState = ClassStateKcls;
        return;
    }
    if ([[SCUDUtil sharedInstance].isMoney integerValue] == 1) {
        if (model.is_charge == YES) {
            if ([model.orderStatus integerValue] != 1) {
                _ClassState = ClassStateisCharge;
                return;
            }
        }
    }
    if ([model.select intValue]==1) {
        _ClassState = ClassStateSeleted;
        return;
    }
    if ([model.isAuth intValue] == 0) {
        _ClassState = ClassStateisAuth;
        return;
    }
    if ([model.isEncrypt  intValue]==1) {
        _ClassState = ClassStateEncrypt;
        return;
    }
    if ([model.select intValue]==0) {
        _ClassState = ClassStateUnSelected;
        return;
    }
    
}






-(void)setClassState:(ClassState)ClassState{
    
    if (_ClassState == ClassState) {
        return;
    }else{
        _ClassState = ClassState;
    }
    
    

}

@end
